package io.xxx.xbutler.core.select.robot;

import io.xxx.xbutler.data.RobotMapper;
import io.xxx.xbutler.domain.Robot;
import io.xxx.xbutler.domain.task.Receiver;
import io.xxx.xbutler.domain.task.Task;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class SampleRobotSelector implements RobotSelector {

    @Resource
    private RobotMapper robotMapper;

    @Override
    public Robot select(Task task, Receiver receiver) {
        return switch (receiver.getType()) {
            case CONTACT -> robotMapper.selectByContact(receiver.getId());
            case ROOM -> robotMapper.selectByRoom(receiver.getId());
        };
    }
}
